/**
 * 结束场景控制器
 */
class endWindowController extends Frame.MVC.Controller {
  view: endWindowView;
  model: gameModel;
  constructor() {
    super();
  }

  viewOpen() {
    this.view.scoreLbl.text = this.model.score.toString();
  }

  viewInit() {
    this.view.returnBtn.addEventListener(egret.TouchEvent.TOUCH_END, this.returnToMain, this);
    this.view.restartBtn.addEventListener(egret.TouchEvent.TOUCH_END, this.restartGame, this);
  }

  private returnToMain() {
    Frame.Game.runScene(SceneKey.main);
  }
  private restartGame() {
    if (typeof (<any>window).sdk !== 'undefined' && (<any>window).sdk.showBanner !== 'undefined') {
      (<any>window).sdk.showBanner();
    }
    this.closeView();
    Frame.Message.dispatch("restart");
  }
}